const express = require('express');
const router = express.Router();
const softwareController = require('../controllers/softwareController');
const { authMiddleware, adminMiddleware } = require('../middleware/auth');

// 公开路由（不需要认证）
router.get('/categories', softwareController.getCategories);
router.get('/popular', softwareController.getPopularSoftware);

// 需要登录的路由
router.use(authMiddleware);

// 获取软件列表
router.get('/', softwareController.getSoftwareList);

// 获取软件详情
router.get('/:id', softwareController.getSoftwareDetail);

// 下载软件
router.post('/:id/download', softwareController.downloadSoftware);

// 管理员路由
router.post('/', adminMiddleware, softwareController.createSoftware);
router.put('/:id', adminMiddleware, softwareController.updateSoftware);
router.delete('/:id', adminMiddleware, softwareController.deleteSoftware);

module.exports = router;
